<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    var ary = [{
        id: 1,
        name: '张三'
    }, {
        id: 2,
        name: '李四'
    }];
    // find() 用于找出第一个符合条件的数组成员，如果没有找到返回 undefined
    let target = ary.find(item => item.id == 2);
    console.log(target);
    </script>
</body>
</html>